package com.mbbb.yygh.task.schedule;

import com.mbbb.yygh.rabbit.RabbitService;
import com.mbbb.yygh.rabbit.constant.MqConst;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling //开启定时任务
public class ScheduledTask {

    @Autowired
    private RabbitService rabbitService;

    /**
     * 每晚八点执行（20点）
     */
    //@Scheduled(cron = "0 0 20 * * ?")
    @Scheduled(cron = "0/10 * * * * ?") //TODO 测试
    public void taskTip() {
        //获取查询的时间
        DateTime dateTime = new DateTime().plusDays(1);
        String dateString = dateTime.toString("yyyy-MM-dd");
        System.out.println(dateString);
        //发送mq消息发送短信
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_8,dateString);
    }
}
